import com.maventools.config.SpringConfig;
import com.maventools.domain.Maven;
import com.maventools.utils.InstallMavenUtils;
import com.maventools.utils.MavenVersionConverter;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;


/**
 * @BelongsProject: maventools
 * @BelongsPackage: PACKAGE_NAME
 * @Author: Layla
 * @CreateTime: 2025-04-20  10:05
 * @Description: TODO
 * @Version: 1.0
 * @Since:Java17
 */
@SpringJUnitConfig(SpringConfig.class)
@RunWith(SpringRunner.class)
public class MavenDownLoader {
    @Autowired
    private InstallMavenUtils imu;
    @Autowired
     private MavenVersionConverter mvc;
    private List<Maven> mavenList;

    @Test
    public void getVersionListTest() throws Exception {
        try {
            mavenList = imu.getMavenList();
            System.out.println(mavenList);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Test
    public void getVersionsTest() throws Exception {
        System.out.println(imu.fetchMavenVersionsFromMavenCentral());
    }

    @Test
    public void installerTest() {
        imu.Installer("3.9.8", true);
    }

    @Test
    public void showTest() {
        try {
            mavenList = imu.getMavenList();
            new MavenVersionConverter().categorizeAndPrintVersions(mavenList);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
@Test
    public void getInstallVersionsTest(){
   List<String> versions=  mvc.getInstallVersions();
   versions.forEach(System.out::println);
}
    }

